package com.hkts.reportform.datastatics.dao;

import java.sql.*;

/**
 * @ClassNametestConnewct
 * @Description
 * @Author yck
 * @Date2021-05-29 14:34
 * @Version V1.0
 **/
public class testConnet {
    public static void main(String[] args) throws Exception {
        String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
        String dbURL="jdbc:sqlserver://192.168.4.4:1433;DatabaseName=data1";
        String userName="sa";
        String userPwd="hkts@1234";
        try
        {
            Class.forName(driverName);
            Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd);
            Statement statement = dbConn.createStatement();
            ResultSet resultSet = statement.executeQuery("select *   from  HKSJFW");
            boolean next = resultSet.next();
            int count=0;
            while(resultSet.next()){
                System.out.println(resultSet.getFloat(3));
                count = count + 1;
            }
            System.out.println("success!");
            dbConn.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            System.out.print("fail!");
        }
    }
}
